<?php

require 'connect.php'; 

$id=  isset($_GET['id'])?$_GET['id']:0;


if (empty($_POST))//判断$_POST是否有数据 
    {
        $sql="SELECT * FROM tb_emp where e_id=$id";
        $result=$dd->query($sql);
        $row=$result->fetch_assoc();
        require 'index_update.php';
    }
    else
        {
            $e_name=$_POST['e_name'];
            $e_dept=$_POST['bumen'];
            $e_img=$_POST['e_img'];
            $date_of_birth=$_POST['date_of_birth'];
            $date_of_entry=$_POST['date_of_entry'];
            $sql="UPDATE tb_emp SET e_name = '$e_name', e_dept = '$e_dept', e_img = '$e_img', date_of_birth = '$date_of_birth', date_of_entry = '$date_of_entry' WHERE e_id = $id;";
            $result=$dd->query($sql);




            if($result)
            {
                echo "<script language='javascript'type='text/javascript'>";
                echo   " alert('修改成功');";
                echo   " window.location.href='index.php';";
                echo    "</script>";
            }
            else
            {
                echo "<script language='javascript'type='text/javascript'>";
                echo   " alert('修改失败');";
                echo   " window.location.href='index.php';";
                echo    "</script>";
            }
        }

